﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GameSite.Models;

namespace GameSite.Controllers
{
    public class GameNewsController : Controller
    {
        private GameA4Context dbContext = new GameA4Context();

        public GameNewsController()
        {
            GlobalViewModel.CacheNews(ViewBag);
        }

        public ActionResult Index()
        {
            var newsCategory = new NewsCategoryModel(dbContext, 0);
            if (newsCategory == null)
            {
                return HttpNotFound();
            }

            return View(newsCategory);
        }

        public ActionResult Details(int id = 0)
        {
            GameNew gamenew = dbContext.GameNews.Find(id);
            if (gamenew == null)
            {
                return HttpNotFound();
            }
            return View(gamenew);
        }

        public ActionResult Activity(int id = 0)
        {
            var Activity = dbContext.Activities.Find(id);
            if (Activity == null)
            {
                return HttpNotFound();
            }
            return View(Activity);
        }  

        public ActionResult Category(int id = 0)
        {
            var newsCategory = new NewsCategoryModel(dbContext, id);
            if (newsCategory == null)
            {
                return HttpNotFound();
            }
            return View(newsCategory);
        }

        protected override void Dispose(bool disposing)
        {
            dbContext.Dispose();
            base.Dispose(disposing);
        }
    }
}